//package com.lengyu.kangdeli.schedules;
//
//import com.lengyu.kangdeli.ding.old.DingDingBasicMethod;
//import com.lengyu.kangdeli.ding.old.IDingSyncService;
//import com.lengyu.kangdeli.entity.ProjectForCode;
//import com.lengyu.kangdeli.excel.ProjectForCodeExcelImportDto;
//import com.lengyu.kangdeli.redis.RedisUtils;
//import com.lengyu.kangdeli.service.ICustomerForCodeService;
//import com.lengyu.kangdeli.service.IFolderStructService;
//import com.lengyu.kangdeli.service.IProjectForCodeService;
//import com.lengyu.kangdeli.service.IProjectService;
//import com.lengyu.kangdeli.youchengCRM.Const;
//import com.lengyu.kangdeli.youchengCRM.SynchronousCRMService;
//import com.lengyu.kangdeli.youchengCRM.YouChengCRMBasicMethod;
//import com.lengyu.kangdeli.youchengCRM.YouChengCRMUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@Component
//public class PersonCountProcessSchedule {
//    private final static Logger logger = LoggerFactory.getLogger(PersonCountProcessSchedule.class);
//
//
//    @Autowired
//    RedisUtils redisUtils;
//
//    @Autowired
//    YouChengCRMBasicMethod youChengCRMBasicMethod;
//
//    @Autowired
//    YouChengCRMUtils youChengCRMUtils;
//
//    @Autowired
//    SynchronousCRMService synchronousCRMService;
//
//    @Autowired
//    IFolderStructService folderStructService;
//
//    @Autowired
//    IProjectService projectService;
//
//    @Autowired
//    IDingSyncService dingSyncService;
//
//    @Autowired
//    ICustomerForCodeService customerForCodeService;
//
//    @Autowired
//    IProjectForCodeService projectForCodeService;
//
//    @Autowired
//    DingDingBasicMethod dingDingBasicMethod;
//
//    /**
//     * 每天凌晨1点
//     * @throws InterruptedException
//     */
////    @Scheduled(fixedDelay = 1000 * 60 * 60*6)
//    @Scheduled(cron = "0 0 1 * * ?")
//    public void  updateCatchRiskPerson(){
//
//
//        dingSyncService.syncDepart();
//        dingSyncService.syncUser();
////
////
////        同步订单信息到项目
////        synchronousCRMService.synchronousFromYouchengCrm(Const.DEPLOY_ID_SALE_ORDER);
//
//        //同步CRM客户信息到客户信息
//        synchronousCRMService.synchronousFromYouchengCrm(Const.DEPLOY_ID_CUSTOMER);
//
//        // 同步CRM销售机会
//        synchronousCRMService.synchronousFromYouchengCrm(Const.DEPLOY_ID_OPPORTUNITY);
//////
//////        projectService.createProjectFolderAll("2023");
////        projectService.createProjectFolderAll("2024");
////        projectService.createProjectFolderAll("2025");
//
////        youChengCRMBasicMethod.getOpenObjectList();
////        youChengCRMBasicMethod.getOpenObjectFieldList(Const.DEPLOY_ID_OPPORTUNITY);
//
//
////        FtpClientUtils.getFileList("/test1");
////        NasFTPUtil.getFileList();
////        FtpClientUtils.mkdirs("/你好/2你");
//
////        folderStructService.createFolderStructJson("101885",false);
////        projectService.createProjectFolderAll("2023");
////        projectService.createProjectFolderAll("2022");
////        projectService.createProjectFolderAll("2021");
////        projectService.createProjectFolderAll("2020");
////        projectService.createProjectFolderAll("2019");
//
////        String year = "2023";
////       s int pageSize =100;
////        QueryWrapper queryWrapper = new QueryWrapper();
////        queryWrapper.orderByAsc("id");
////        queryWrapper.eq("type","设备");
////        String startTime = year + "-01-01 00:00:00";
////        String endTime = year + "-12-31 23:59:59";
////        queryWrapper.between("contract_date",startTime,endTime);
////        int count = projectService.count(queryWrapper);
////        for(int i=0;i<(count/pageSize) + 1;i++){
////            Page<Project> projectPage = projectService.page(new Page(i, pageSize),queryWrapper);
////            if(projectPage.getRecords() != null && projectPage.getRecords().size() > 0){
////                projectPage.getRecords().forEach(j->{
////                    folderStructService.checkEmptyFolder(j.getId());
////                });
////            }
////        }
////        folderStructService.checkEmptyFolder("136559");
//
//        //         youChengCRMBasicMethod.getOpenDataList(Const.DEPLOY_ID_CUSTOMER,1,1,null);
////        youChengCRMBasicMethod.getOpenObjectFieldList(Const.DEPLOY_ID_CUSTOMER);
//
//    }
//
////    /**
////     * 读取excel客户编码及项目编码
////     */
////    @Scheduled(fixedDelay = 1000 * 60 * 60*6)
////    public void  readExcel() {
////        ReadExcelUtil readExcelUtil = new ReadExcelUtil();
////        String fileName = "D:\\src\\kangdeli_back\\kangdeli_manage\\合同编号及客户编号.xlsx";
////
////        List<CustomExcelImportDto> customList = readExcelUtil.readExcel(2, 2, fileName,
////                CustomExcelImportDto.class);
////
////        List<CustomerForCode> customerForCodeList = convertCustomerForCodeListFromCrm(customList);
////        logger.info(JSONObject.toJSONString(customList));
////        customerForCodeService.saveOrUpdateBatch(customerForCodeList,100);
////
////
////
////        List<ProjectForCodeExcelImportDto> projectList = readExcelUtil.readExcel(0, 2, fileName,
////                ProjectForCodeExcelImportDto.class);
////        logger.info(JSONObject.toJSONString(projectList));
////        List<ProjectForCode> projectForCodeList = convertProjectForCodeListFromCrm(projectList);
////        for (ProjectForCode projectForCode : projectForCodeList) {
////
////            projectForCodeService.saveOrUpdate(projectForCode);
////
////        }
////
////    }
//
//    private List<ProjectForCode> convertProjectForCodeListFromCrm(List<ProjectForCodeExcelImportDto> projectForCodeList) {
//        List<ProjectForCode> projectList = new ArrayList<>();
//        if(projectForCodeList !=null && projectForCodeList.size() > 0){
//            projectForCodeList.forEach(i->{
//                if (StringUtils.isNotBlank(i.getProjectCode())) {
//                    i.setProjectCode(i.getProjectCode().replace("'",""));
//                    ProjectForCode project = new ProjectForCode();
//                    project.setId(i.getProjectCode());
//                    project.setCode(i.getProjectCode());
//                    project.setCustomerId(i.getCustomId());
//                    project.setCustomerName(i.getCustomName());
//                    project.setCreateId("excel导入");
//                    if(StringUtils.isNotBlank(project.getCode()) && project.getCode().length() > 7){
//                        String sortNoStr = project.getCode().substring(project.getCode().length() - 4,
//                                project.getCode().length() - 1);
//                        try{
//                            project.setSortNo(Integer.parseInt(sortNoStr));
//                        }
//                        catch(Exception ex){
//                            project.setSortNo(0);
//                        }
//                        String yearStr = project.getCode().substring(project.getCode().length() - 6,
//                                project.getCode().length() - 4);
//                        try{
//                            project.setYear(Integer.parseInt(yearStr));
//                        }
//                        catch (Exception ex){
//                            project.setYear(0);
//                        }
//
//                        String typeStr = project.getCode().substring(project.getCode().length() - 1);
//                        try{
//                            project.setType(typeStr);
//                        }
//                        catch (Exception ex){
//                            project.setType("-1");
//                        }
//
//                    }
//
//                    projectList.add(project);
//                }
//            });
//        }
//        return projectList;
//    }
//
//
//
//}
